import { legacy_createStore, applyMiddleware } from "redux"
import thunk from "redux-thunk"
import logger from "redux-logger"
import { ALLSTATE,ALLACTIONS, SETLISTTYPE, SETLISTDATA } from "../types/store.d"

const initialState = {
  testData: "",
  list: []
}

const reducer = (state: ALLSTATE = initialState, { type, payload }: ALLACTIONS) => {
  switch (type) {
    case SETLISTTYPE:
      state.testData = payload
      return { ...state }
    case SETLISTDATA:
    state.list=payload
      return { ...state }
    default:
      return state
  }
}
const store = legacy_createStore(reducer, applyMiddleware(thunk, logger))
export default store

// rxr